<h4><i class="fa fa-tag"></i> <?php echo Yii::t('helpdesk','Forward ticket'); ?></h4><hr>
<?php 
foreach(Yii::app()->user->getFlashes() as $key => $message){
	echo '<div class="'.$key.'"><p>'.$message."</p></div>\n";
}
?>
<?php 
	$arrTicketCates = HelpDesk::getInstance()->analyseTicketCategory($post['post_category_id'], $arrDepts);
	$ticketDepartment = $arrTicketCates['department'];
	$ticketSubject = $arrTicketCates['subject'];	
?>
<a href="javascript:void(0);" onClick="window.history.back(-1);"><i title="go back" class="fa fa-arrow-left"></i> <?php echo Yii::t('helpdesk','Go back'); ?></a>
<form id="frmForward" class="form-horizontal" enctype="multipart/form-data" method="post">
<table style="width:100%;" class="table table-nonfluid table-condensed">
<tbody>
	<tr style="border:none;">
    	<td colspan="2" style="border:none;"><h4><?php echo Yii::t('helpdesk','Forward ticket'); ?> [#<?php echo $post['post_id'];?>]</h4></td>
    </tr>
	<tr>
        <td><?php echo Yii::t('helpdesk','Title'); ?></td>
        <td><?php echo $post['post_title']; ?></td>
	</tr>
 	<tr>
        <td width="80px"><?php echo Yii::t('helpdesk','Urgency'); ?></td>
        <td>
			<?php 
				if(isset($post['fields']['helpdesk-urgency'])){
					switch($post['fields']['helpdesk-urgency']){
						case '1': echo '<span class="urg_1">'.Yii::t('helpdesk','Low').'</span>'; break;
						case '2': echo '<span class="urg_2">'.Yii::t('helpdesk','Medium').'</span>'; break;
						case '3': echo '<span class="urg_3">'.Yii::t('helpdesk','High').'</span>';
					}
				}
			?>
        </td>
	</tr>
	<tr>
        <td><?php echo Yii::t('helpdesk','Status'); ?></td>
        <td><?php echo ($post['post_status']=='1')?'<span class="open">'.Yii::t('helpdesk','Open').'</span>':'<span class="closed">'.Yii::t('helpdesk','Closed').'</span>'; ?></td>
	</tr>
    <tr>
    	<td colspan="2"><h4><?php echo Yii::t('helpdesk','From'); ?></h4></td>
    </tr>
	<tr>
		<td><?php echo Yii::t('helpdesk','Department'); ?></td>
        <td><?php echo !empty($ticketDepartment['category_name'])?$ticketDepartment['category_name']:null ?></td>
    </tr>
    <tr>
		<td><?php echo Yii::t('helpdesk','Subject'); ?></td>
        <td><?php echo !empty($ticketSubject['category_name'])?$ticketSubject['category_name']:null ?></td>
    </tr>
    <tr>
    	<td colspan="2"><h4><?php echo Yii::t('helpdesk','To'); ?></h4></td>
    </tr> 
	<tr <?php if(!empty($dept_id)): ?>style="display:none;"<?php endif; ?>>
    	<td><?php echo Yii::t('helpdesk','Department'); ?></td>
        <td>
        	<select id="dept" name="dept[]" class="form-control" required>
            	<option value="">-- <?php echo Yii::t('helpdesk','Choose'); ?> --</option>
				<?php foreach($arrDepts as $R): ?>
                <?php if($R['category_level'] == 0): ?>
                <option  value="<?php echo $R['category_id']; ?>" <?php if(!empty($dept_id) && $dept_id == $R['category_id']): ?>selected<?php endif?>><?php echo $R['category_name']; ?></option>
                <?php endif; ?>
				<?php endforeach; ?>
            </select>
        </td>
    </tr>
    
    <tr>
    	<td><?php echo Yii::t('helpdesk','Subject'); ?></td>
        <td><select id="subject" name="dept[]" class="form-control"></select></td>
    </tr>
</tbody>
</table>
<input type="hidden" name="postId" value="<?php echo $post['post_id']; ?>">
<input type="submit" class="btn btn-large btn-primary" value="<?php echo Yii::t('helpdesk','Save'); ?>">
</form>
<script type="text/javascript">
	var depts = new Array();
	<?php foreach($arrDepts as $R): ?>
	<?php if($R['category_level'] == 0): ?>depts[<?php echo $R['category_id']; ?>] = new Array();<?php else: ?>depts[<?php echo $R['category_parent']; ?>][<?php echo $R['category_id']; ?>] = "<?php echo $R['category_name']; ?>"; <?php endif; ?>
	<?php endforeach; ?>
	$(document).ready(function(){
		loadSubjects($('#frmForward select[id=dept]').val(), '', $('#frmForward select[id=subject]'));
		$('#frmForward select[id=dept]').change(function(){
			loadSubjects($(this).val(), '', $('#frmForward select[id=subject]'));
		});
	});
</script>